using System;
using System.Web.Security;
using System.Web.UI.WebControls;
using SouthernLand.Common;

namespace SouthernLand.WebMaster.Membership
{
    public partial class ManageUsers : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string[] roles = Roles.GetAllRoles();
                RolesDropDownList.DataSource = roles;
                RolesDropDownList.DataBind();
            }

            NewUser.Text = ResourceManager.GetString("Membership_Add");
            NewUser.NavigateUrl = Globals.ApplicationPath + "WebMaster/Membership/CreateUser.aspx";
        }

        protected void btDelete_Click(object sender, EventArgs e)
        {
            foreach (GridViewRow row in GridViewItem.Rows)
            {
                bool isChecked = ((CheckBox) row.FindControl("chkSelect")).Checked;
                if (isChecked)
                {
                    string UserName = (((CheckBox) row.FindControl("chkSelect")).ToolTip.Trim());
                    //ProfileManager.DeleteProfile(UserName);
                    System.Web.Security.Membership.DeleteUser(UserName);
                }
            }
            DataBind();
        }

        protected void btSearch_Click(object sender, EventArgs e)
        {
            GridViewItem.DataSourceID = "SearchDataSource";
        }
    }
}